<?php

session_start();

require "include/template2.inc.php";
require "include/beContent.inc.php";
require "include/content.inc.php";

/*

$type[1] = 5; //libro
$type[2] = 1; //rivista
$type[3] = 3; //conf
$type[4] = 7; //tr

$persona['alfonso'] = 'alfonso';
$persona['adimarco'] = 'adimarco';
$persona['flammini'] = 'flammini';
$persona['inverardi'] = 'paola.inverardi';
$persona['stefania'] = 'scostantini';
$persona['lopresti'] = 'lopresti';
$persona['mancinelli'] = 'mancinelli';
$persona['melatti'] = 'melatti';
$persona['vittorio.bilo'] = 'vittorio.bilo';
$persona['dellapenna'] = 'gdellapenna';
$persona['flavio'] = 'flavio';
$persona['proietti'] = 'gproietti';
$persona['caporuscio'] = 'caporuscio';
$persona['pelliccione'] = 'pelliccione';
$persona['melideo'] = 'gmelideo';
$persona['castaldi'] = 'castaldi';
$persona['muccini'] = 'hmuccini';
$persona['monica'] = 'mnesi';
$persona['rossi'] = 'frossi';
$persona['orefice'] = 'sorefice';
$persona['forlizzi'] = 'lforlizzi';
$persona['smriglio'] = 'ssmriglio';
$persona['navarra'] = 'navarra';
$persona['bianchi'] = 'bianchi';
$persona['diruscio'] = 'diruscio';
$persona['servilio'] = 'servilio';
$persona['tivoli'] = 'mtivoli';
$persona['arbib'] = 'claudio.arbib';
$persona['formisano'] = 'formisano';
$persona['marinelli'] = 'marinelli';
$persona['cortellessa'] = 'vcortellessa';
$persona['autili'] = 'autili';
$persona['cicchetti'] = 'cicchetti';
$persona['mostarda'] = 'mostarda';



$pubs = aux::getResult("SELECT * FROM publications ORDER BY year DESC");



$today = date('YmdHi');

foreach($pubs as $item) {
	
	$venue = "";
	foreach($item as $k => $v) {
		$item[$k] = addslashes($v);
	}
	
	
	switch ($item['id_type']) {
		case 1:
			$venue = "{$item['booktitle']}";
			
			break;
		case 2: 
			$venue = "{$item['journal']}";
			
			if ($item['volume'] != "") {
				$venue .= " ({$item['volume']}):{$item['number']}";
			}
			
		
			break;
		case 3:
			
			$venue .= "{$item['conference']}";
			if ($item['booktitle']!= "") {
				$venue .= ", {$item['booktitle']}";
			}
			
			break;
		case 4:
			$venue = " {$item['institution']}, Tech. Report";
			
			if ($item['tr_number'] != "") {
				$venue .= " {$item['year']}/{$item['tr_number']}";
			}
			
			break;
	}
	
	if ($item['pages'] != "") {
		
		$item['pages'] = str_replace("--", "-", $item['pages']);
		
		$venue .= ", ".aux::lingual("pagg.", "pages")." {$item['pages']}";
	}
	
	$item['title'] = str_replace("``", "\"", $item['title']);
	
	
	$oid = mysql_query("INSERT INTO publication VALUES (
		NULL, 
		'{$persona[$item['username']]}', 
		'{$today}', '{$today}',
		'{$item['title']}',
		'{$item['authors']}',
		'',
		'{$item['year']}',
		'{$venue}',
		'type',
		'',
		'',
		'',
		'')
	");
	
	mysql_query("INSERT INTO users VALUES(
		'{$persona[$item['username']]}',
		'hansaplast',
		'null',
		'{$persona[$item['username']]}',
		'',
		'','','','',
		'8',
		'','',
		'','','',''
	)");
	
	if (!$oid) {
		echo mysql_error();
		exit;
	}
} */


$data = aux::getResult("SELECT * FROM publication");

foreach($data as $item) {
	$oid = mysql_query("DELETE FROM {$pubAuthors->name} WHERE id_publication = {$item['id']} and username = '{$item['username']}'");
	$oid = mysql_query("INSERT INTO {$pubAuthors->name} VALUES({$item['id']}, '{$item['username']}')");
	
	echo "<b>{$item['username']}</b>:<br>{$item['title']}<br>{$item['authors']}";
	
	
	
	echo "<br><br>";
	
}


?>